#include "Casa.h"

Casa::Casa()
{
	Cor = BRANCO;
	float BrancoAmbient[4] = {255.0,255.0,255.0,0};
	float BrancoDifuse[4] = {0.0,0.0,0.0,0.0};
	float BrancoSpec[4] = {0.0,0.0,0.0,0.0};
	float BrancoShineness = 10.0;
	branco = new CGFappearance(BrancoAmbient,BrancoDifuse,BrancoSpec,BrancoShineness);
	float PretoAmbient[4] = {0,0,0,1};
	float PretoDifuse[4] = {0.0,0.0,0.0,0.0};
	float PretoSpec[4] = {0.0,0.0,0.0,0.0};
	float PretoShineness = 10.0;
	preto = new CGFappearance(PretoAmbient,PretoDifuse,PretoSpec,PretoShineness);
}

void Casa::setCor(int estado)
{
	Cor = estado;
}

int Casa::getCor()
{
	return Cor;
}

void Casa::setBranco(CGFappearance* NovaAp)
{
	branco = NovaAp;
}

void Casa::setPreto(CGFappearance* NovaAp)
{
	preto = NovaAp;
}

void Casa::draw()
{
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	if(Cor == BRANCO)
	{
		glBlendFunc(GL_ZERO, GL_ZERO);
		branco->apply();
	}
	else
	{
		glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE_MINUS_SRC_COLOR);
		preto->apply();
	}
	glBegin(GL_POLYGON);
		glNormal3f(0,1,0);
		glTexCoord2f(0.0,0.0);
		glVertex3d(-0.5,0,-0.5);
		glTexCoord2f(1.0,0.0);
		glVertex3d(-0.5,0,0.5);
		glTexCoord2f(0.0,1.0);
		glVertex3d(0.5,0,0.5);
		glTexCoord2f(1.0,1.0);
		glVertex3d(0.5,0,-0.5);
	glEnd();
	glDisable(GL_BLEND);
	glDisable(GL_TEXTURE_2D);
}